<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="vue.js"></script>
    <script src="jquery.min.js"></script>
    <style>
        body {
            margin: 0;
        }

        section {

            border: 1px solid black;
            height: 10px;
            width: 500px;
            position: relative;
        }

        section>div {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            border: 1px solid #000;
            position: absolute;
        }
    </style>
</head>

<body>
    <main id="app">
        <first-com></first-com>
    </main>
    <script id="first" type="text/html">
        <div>
            <input type="text">
            <br><br>
            <section @mousedown='move'>
                <div class='yuan' :style='divmove'></div>
            </section>
        </div>
    </script>
    <script>
        Vue.component('first-com', {
            template: '#first',


            methods: {
                move: function () {
                    console.log('点击了')
                    var point = function (e) {
                        var pointX = e.pageX
                        if (pointX < 0) {
                            pointX = 0
                        }
                        if (pointX > this.length) {
                            pointX = this.length
                        }
                        var position = pointX / (this.length - 10) * 100

                        if (position > 100) {
                            position = 100
                        }
                        // this.$emit('input', position)
                        console.log(pointX)
                    }
                    document.addEventListener('mousemove', point)

                    document.addEventListener('mouseup', function () {

                        document.removeEventListener('mousemove',point)
                    }) 
                },
            }

        })
        var vue = new Vue({
            el: "#app"
        })    
    </script>
</body>

</html>